package com.xja.zf.service.impl;

import com.xja.zf.entity.Users;
import com.xja.zf.mapper.UsersMapper;
import com.xja.zf.service.UsersService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

/**
 * @program: zf_system
 * @description:
 * @author: 李晓龙
 * @create: 2021-12-23 11:19
 **/
@Component
@Service(interfaceClass = UsersService.class)
public class UserServcieImpl implements UsersService {
    @Autowired
    private UsersMapper usersMapper;

    //查询用户名是否已经存在
    @Override
    public Users selectUserExist(String loginName) {
        return usersMapper.selectUserExist(loginName);
    }

    //注册
    @Override
    public int insertSelective(Users record) {
        return usersMapper.insertSelective(record);
    }

    @Override
    @Transactional(readOnly = true)
    public Users login(Users users) throws Exception {
        Users users1=usersMapper.selectByName(users.getName());
        if(users1!=null){
            if(users1.getPassword().equals(users.getPassword())){
                return users1;
            }
        }
        return null;
    }
}
